import { createStore } from 'vuex'
import createPersistedState from "vuex-persistedstate";//持久化库
export default createStore({
  state: {
    webuserInfo:{},
    webpaystate:{},
  },
  getters: {
  },
  mutations: {
    webchangeUserInfo(state,value){
      state.webuserInfo = {
        ...state.webuserInfo,
        ...value
      }
    },
    changewebpaystate(state,value){
      state.webpaystate = {
        ...state.webpaystate,
        ...value
      }
    },
    clearUserInfo(state,value){
      state.webuserInfo = {}
    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[createPersistedState({
    paths:["webuserInfo","webpaystate"] //控制是否持久化
  })],//持久化
})


// router.beforeEach((to,from,next)=>{
//   if(!localStorage.getItem("token")){//获取本地存储token
//     next({ //next 拦截之后。。
//       path:"/"  //重定向
//       // alert("请先登陆")
//     })
//   }
// })